package com.crl.module.cmpRpc.factory
{
	import com.crl.core.config.section.model.ConnectionStringSetting;
	import com.crl.module.cmpRpc.behavior.AbstractRequestBehavior;
	import com.crl.module.cmpRpc.behavior.AmfRequest;
	
	import flash.events.NetStatusEvent;
	import flash.net.NetConnection;
	
	/**
	 * amf 远程方法调用策略工厂,主要为不多创建netconnection实例;
	 * @author crl
	 * 
	 */	
	public class AMFRequestFactory implements IRequestorFactory
	{
		//private var service:Service;
		private var netconnection:NetConnection;
		public function AMFRequestFactory(conn:ConnectionStringSetting)
		{
			netconnection=new NetConnection();
			netconnection.addEventListener(NetStatusEvent.NET_STATUS,netStauts);
			
			netconnection.connect(conn.connectionString);
			//service=ServiceFactory.getInstance(conn.connectionString);
		}
		
		private function netStauts(event:NetStatusEvent):void{
			trace(event.info);
		}
		
		public function createRequestBehavior():AbstractRequestBehavior
		{
			return new AmfRequest(netconnection);
		}
	}
}